package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.entity.Result;
import com.itheima.mapper.MenuMapper;
import com.itheima.pojo.Menu;
import com.itheima.service.MenuService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

import static com.itheima.constant.MessageConstant.QUERY_MENU_FAIL;
import static com.itheima.constant.MessageConstant.QUERY_MENU_SUCCESS;

@Service(version = "1.0",interfaceClass = MenuService.class)
@Transactional
public class MenuServiceImpl implements MenuService {
    @Resource
    MenuMapper menuMapper;

    @Override
    public Result findAll() {
        try {
            List<Menu> menuList = menuMapper.findAll();
            return Result.success(QUERY_MENU_SUCCESS,menuList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.fail(QUERY_MENU_FAIL);
    }
}
